import { getToken } from '../../../utils/getToken'

Page({
  data:{
    repairList:[]
  },
  onLoad(){
    this.getRepairList()
  },
  getRepairList(){
    wx.request({
      url: 'https://live-api.itheima.net/repair',
      method:'GET',
      header:{
        Authorization: 'Bearer ' + getToken()
      },
      data:{
        current:1,
        pageSize:10
      },
      success:(res)=>{
        console.log('报修房屋列表success', res)
        if(res.data.code!==10000){
          return wx.showToast({
            title: res.data.message,
          })
        }
        this.setData({
          repairList:res.data.data.rows
        })
      }
    })
  },
  goDetail(e) {
    wx.navigateTo({
      url: `/repair_pkg/pages/detail/index?id=${e.mark.id}`,
    })
  },
  addRepair() {
    wx.navigateTo({
      url: '/repair_pkg/pages/form/index',
    })
  },
})
